<script>
	import jwtDecode from 'jwt-decode';
	export default {
		onLaunch: function() {
			console.log('App Launch')
			//小程序强制重启刷新刷新
			const updateManager = wx.getUpdateManager()
			updateManager.onCheckForUpdate(function(res) {
				if (res.hasUpdate) {
					updateManager.onUpdateReady(function(ress) {
						updateManager.applyUpdate()
					})
				} else {
					updateManager.onUpdateFailed(function() {})
				}

			})
			if (uni.getStorageSync('token') !== '') {
				const token = uni.getStorageSync('token')
				const decodedToken = jwtDecode(token);
				const expirationTime = decodedToken.exp;
				const currentTime = new Date().getTime() / 1000;
				if (currentTime > expirationTime) {
					uni.showToast({
						title: '您的登陆已过期'
					});
					uni.navigateTo({
						url: '/pages/public/login'
					});
				}
			}
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},

	}
</script>

<style>
	/*每个页面公共css */
	@import '/common/css/common.css';
	@import '/common/css/iconfont.css';
	@import '/common/css/animate.min.css';
</style>